#!/usr/bin/bash
#这里加一个判断tty的命令
#因为我的电脑是deepin系统，tty1是图形化，tty7不知道是啥，所以
#只要是tty3-tty6都可以用，后面安装显卡驱动的要求，不再图形化下面安装
echo "because tty not show chinese so ....."

TTY=`tty`

case $TTY in
    "/dev/tty2" | "/dev/tty3" | "/dev/tty4" | "/dev/tty5" | "/dev/tty6") echo 'running in TTY'
    ;;
    *) echo -e "running not in TTY\n"; exit
    ;;
esac

echo -n "please enter your passwd:"
read -s PASSWD

#设置vim的配置文件
cat >> ${HOME}/.vimrc << EOF
set number

set syntax=on

set tabstop=4

set softtabstop=4

set autoindent

set completeopt=preview,menu
EOF


#下载dock网速插件
wget https://gitee.com/q77190858/dde-sys-monitor-plugin/raw/master/bin/libsys_monitor.so
echo ${PASSWD}|sudo -S mv libsys_monitor.so /usr/lib/dde-dock/plugins/
#重启dock
pkill dde-dock


#先安装zsh
echo ${PASSWD}|sudo -S apt-get install zsh git
#在安装oh——my——zsh
echo ${PASSWD}|sudo -S tee -a /etc/hosts << EOF
#zsh安装脚本的域名的ip地址
185.199.111.133         raw.githubusercontent.com
EOF

#这个ip地址下载的快
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O install_zsh.sh
#赋权
chmod +x install_zsh.sh
#安装
#这里要修改一下

ehco ${PASSWD}| ./install_zsh.sh
#下载常用插件
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
#先修改自己喜欢的主题
rm ${HOME}/.oh-my-zsh/themes/frisk.zsh-theme -f
cat >> ${HOME}/.oh-my-zsh/themes/frisk.zsh-theme << EOF
PROMPT=$'
%{$fg[blue]%}%/%{$reset_color%} $(git_prompt_info)$(bzr_prompt_info)%{$fg[yellow]%}[%n@%m]%{$reset_color%} %{$fg[blue]%}[%*]%{$reset_color%}
%{$fg_bold[red]%}>%{$reset_color%} '

PROMPT2="%{$fg_blod[black]%}%_> %{$reset_color%}"

GIT_CB="git::"
ZSH_THEME_SCM_PROMPT_PREFIX="%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_PREFIX=$ZSH_THEME_SCM_PROMPT_PREFIX$GIT_CB
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""s
EOF

#修改.文件zshrc
sed -i -r 's/^ZSH_THEME=".*?"/ZSH_THEME="frisk"/g' ${HOME}/.zshrc
#修改出自己喜欢的插件
sed -r 's/^plugins\=\(.*?\)/plugins\=\(git sudo zsh-autosuggestions zsh-syntax-highlighting\)/g' ${HOME}/.zshrc
#zsh-syntax-highlighting的配置
echo -e '# Note the source command must be at the end of .zshrc\nsource "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"' >> ${HOME}/.zshrc
#到此为止zsh基本配置完成

#接下来就是常用软件的安装
echo ${PASSWD} |sudo -S tee -a /etc/apt/sources.list.d/google-chrome.list << EOF
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
EOF

echo ${PASSWD}|sudo -S apt-get update &&echo ${PASSWD}|sudo -S apt-get upgrade
echo ${PASSWD}|sudo -S apt-get install google-chrome-stable com.visualstudio.code cn.wps.wps-office \
 com.baidu.baidunetdisk com.xunlei.download io.typora org.freedownloadmanager.fdm \
 com.qq.im.deepin com.163.music com.qq.weixin.deepin lua axel tree python3-pip

#修改pip源
mkdir ${HOME}/.pip
cat ${HOME}/.pip/pip.conf << EOF
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com
EOF

#这里添加自己的几个小脚本
mkdir ${HOME}/.local/bin
wget https://gitee.com/jianghuchuan_kebei/miscellaneous/raw/master/ip138 -O ${HOME}/.local/bin/ip138
wget https://gitee.com/jianghuchuan_kebei/miscellaneous/raw/master/fanyi -O ${HOME}/.local/bin/fanyi
wget https://gitee.com/jianghuchuan_kebei/miscellaneous/raw/master/yaopin -O ${HOME}/.local/bin/yaopin
pip3 install requests js2py matplotlib
chmod +x ${HOME}/.local/bin -R
cat >> ${HOMe}/.zshrc << EOF
source "${HOME}/.profile"
EOF


#然后安装todesktop
wget https://update.todesk.com/linux/todesk_1.2.4d_amd64.deb
echo ${PASSWD}|sudo -S dpkg -i todesk_1.2.4d_amd64.deb

#然后安装virtualbox
wget https://download.virtualbox.org/virtualbox/6.1.18/virtualbox-6.1_6.1.18-142142~Debian~buster_amd64.deb
echo ${PASSWD}|sudo -S dpkg -i https://download.virtualbox.org/virtualbox/6.1.18/virtualbox-6.1_6.1.18-142142~Debian~buster_amd64.deb

#然后更新内核
echo ${PASSWD}|sudo -S apt-get install linux-headers-deepin-stable-amd64 linux-image-deepin-stable-amd64 

#然后下载nvidia显卡的安装脚本
wget https://github.com/Sino-Huang/Deepin_installation_tips/releases/download/0.1/deepin_nvidia_install_2.sh
#修改软件源
#下面这个命令没用了，作者自己把源修改成国内源了
#sed -i 's/deb_source="deb http://deb.debian.org/debian buster-backports main contrib non-free"/deb_source="deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free"/g' deepin_nvidia_install_2.sh
#安装显卡
echo ${PASSWD}|sudo -S bash deepin_nvidia_install_2.sh laptop
#这里安装deepin_nvidia_install_2.sh这个脚本会有一个重新启动的命令，这也是为什么把这个放在最后